<template>
  <el-date-picker
    v-model="queryKey"
    style="width:100%"
    v-bind="attrs"
    type="year"
    :title="realText"
    @change="handleEvent('change', $event)"
    @blur="handleEvent('blur', $event)"
    @focus="handleEvent('focus', $event)"
  />
</template>
<script>
import componentMixin from '@admin/packages/table-filter/src/mixins/mixin.js'
const DEFAULT_CONFIG = {
  'value-format': 'yyyy',
  'format': 'yyyy'
}
export default {
  name: 'EleDistype1041',
  mixins: [componentMixin],
  props: {
    conf: {
      type: Object,
      required: true
    },
    tableFilter: {
      type: Boolean,
      default: false
    }
  },
  data() {
    return {
    }
  },
  computed: {
    queryKey: {
      get: function() {
        const value = this.query[this.key]
        return value ? new Date((value + '-01-01')) : ''
      },
      set: function(newValue) {
        this.query[this.key] = newValue
      }
    },
    config: function() {
      return this.conf.__config__
    },
    key: function() {
      return this.config.key
    },
    tag: function() {
      return this.config.tag
    },
    attrs: function() {
      // 筛选非__开头的属性
      const attrs = Object.assign({}, this.conf)
      Object.keys(attrs).filter((item) => {
        if (item.indexOf('__') === 0) {
          delete attrs[item]
        }
      })
      const connectOption = {
        disabled: this.isFieldDisabled(this.conf)
      }
      let outAttr = {}
      if (window.$CD && window.$CD.fieldAttr && window.$CD.fieldAttr[this.key]) {
        outAttr = window.$CD.fieldAttr[this.key]
      }
      return Object.assign({}, DEFAULT_CONFIG, connectOption, attrs, this.fieldAttrs, outAttr)
    }
  },
  mounted: function() {
    console.log(this.$attrs)
  }
}
</script>

